var notif = require('../../core/notifications'),
	util = require('../../core/module.js');

var config = new util.ConfigModule('security'); // configuration file

function execute(dummyData, id_module) // this action is called whenever the door sensor is activated
{
	config.get(id_module, function(err, conf)
	{
		if(conf['secured'] == true)
		{
			var payload = {message: 'ALERT: SOMEBODY ENTERED YOUR HOUSE. STOP. CALL THE COPS IMMEDIATLY. STOP.'};
			console.log('Door sensor activated and ALARM IS SET. Sending push notification');
			notif.notify('alarm', JSON.stringify(payload));
		}
		else
			console.log('Door sensor was activated but NO alarm is set.');
	});
}

exports.execute = execute;
